package com.alibaba.citrus.cr.mn.order.center.facade.covert;

import com.alibaba.citrus.cr.mn.order.center.common.util.nvlToEmptyUtils;
import com.epoch.app.mnordercenter.model.dto.SalesOrderAtomQueryDetailResponse;
import com.epoch.app.mnordercenter.model.dto.SalesOrderAtomQueryResponse;
import com.epoch.app.mnordercenter.model.dto.SalesOrderGroupQueryDetailResponse;
import com.epoch.app.mnordercenter.model.dto.SalesOrderGroupQueryResponse;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class SalesOrderAtomQueryResponseToSalesOrderGroupQueryResponse {

	public static List<SalesOrderGroupQueryResponse> convert(List<SalesOrderAtomQueryResponse> salesOrderAtomQueryResponseList) {
		 List<SalesOrderGroupQueryResponse> response = new ArrayList<>(salesOrderAtomQueryResponseList.size());
		if (CollectionUtils.isEmpty(salesOrderAtomQueryResponseList)) {
			return response;
		}
		SalesOrderGroupQueryResponse salesOrderGroupQueryResponse = null;
		for (SalesOrderAtomQueryResponse order : salesOrderAtomQueryResponseList) {
			salesOrderGroupQueryResponse = new SalesOrderGroupQueryResponse();
			salesOrderGroupQueryResponse.setOrderCategoryCode(order.getOrderCategoryCode());
			salesOrderGroupQueryResponse.setOrderCategoryName(order.getOrderCategoryName());
			salesOrderGroupQueryResponse.setOrderChannelCode(nvlToEmptyUtils.nvlToEmptyStr(order.getOrderChannelCode()));
			salesOrderGroupQueryResponse.setOrderChannelName(nvlToEmptyUtils.nvlToEmptyStr(order.getOrderChannelName()));
			salesOrderGroupQueryResponse.setPreOrderNo(nvlToEmptyUtils.nvlToEmptyStr(order.getPreOrderNo()));
			salesOrderGroupQueryResponse.setSourceOrderNo(nvlToEmptyUtils.nvlToEmptyStr(order.getSourceOrderNo()));
			salesOrderGroupQueryResponse.setOutOrderNo(nvlToEmptyUtils.nvlToEmptyStr(order.getOutOrderNo()));
			salesOrderGroupQueryResponse.setFromSys(order.getFromSys());
			salesOrderGroupQueryResponse.setBusinessType(order.getBusinessType());
			salesOrderGroupQueryResponse.setBusinessTypeName(nvlToEmptyUtils.nvlToEmptyStr(order.getBusinessTypeName()));
			salesOrderGroupQueryResponse.setBusinessUnitCode(order.getBusinessUnitCode());
			salesOrderGroupQueryResponse.setBusinessUnitName(order.getBusinessUnitName());
			salesOrderGroupQueryResponse.setSalesOrderType(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesOrderType()));
			salesOrderGroupQueryResponse.setSalesOrderTypeName(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesOrderTypeName()));
			salesOrderGroupQueryResponse.setBusinessChannel(nvlToEmptyUtils.nvlToEmptyStr(order.getBusinessChannel()));
			salesOrderGroupQueryResponse.setBusinessChannelName(nvlToEmptyUtils.nvlToEmptyStr(order.getBusinessChannelName()));
			salesOrderGroupQueryResponse.setSalesOrganizationCode(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesOrganizationCode()));
			salesOrderGroupQueryResponse.setSalesOrganizationName(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesOrganizationName()));
			salesOrderGroupQueryResponse.setProductGroupCode(nvlToEmptyUtils.nvlToEmptyStr(order.getProductGroupCode()));
			salesOrderGroupQueryResponse.setProductGroupName(nvlToEmptyUtils.nvlToEmptyStr(order.getProductGroupName()));
			salesOrderGroupQueryResponse.setCustomerCode(order.getCustomerCode());
			salesOrderGroupQueryResponse.setCustomerName(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerName()));
			salesOrderGroupQueryResponse.setShipToPartyCode(order.getShipToPartyCode());
			salesOrderGroupQueryResponse.setShipToPartyName(nvlToEmptyUtils.nvlToEmptyStr(order.getShipToPartyName()));
			salesOrderGroupQueryResponse.setSalesChannelCode(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesChannelCode()));
			salesOrderGroupQueryResponse.setSalesChannelName(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesChannelName()));
			salesOrderGroupQueryResponse.setSalesDepartmentCode(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesDepartmentCode()));
			salesOrderGroupQueryResponse.setSalesDepartmentName(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesDepartmentName()));
			salesOrderGroupQueryResponse.setCostCenterCode(nvlToEmptyUtils.nvlToEmptyStr(order.getCostCenterCode()));
			salesOrderGroupQueryResponse.setCostCenterName(nvlToEmptyUtils.nvlToEmptyStr(order.getCostCenterName()));
			salesOrderGroupQueryResponse.setOrderStatus(nvlToEmptyUtils.nvlToEmptyStr(order.getOrderStatus()));
			salesOrderGroupQueryResponse.setExpectedDeliveryDate(nvlToEmptyUtils.nvlToEmptyStr(order.getExpectedDeliveryDate()));
			salesOrderGroupQueryResponse.setDeliveryMethodCode(nvlToEmptyUtils.nvlToEmptyStr(order.getDeliveryMethodCode()));
			salesOrderGroupQueryResponse.setDeliveryMethodName(nvlToEmptyUtils.nvlToEmptyStr(order.getDeliveryMethodName()));
			salesOrderGroupQueryResponse.setCreatorCode(nvlToEmptyUtils.nvlToEmptyStr(order.getCreatorCode()));
			salesOrderGroupQueryResponse.setCreatorName(nvlToEmptyUtils.nvlToEmptyStr(order.getCreatorName()));
			salesOrderGroupQueryResponse.setCreateTime(nvlToEmptyUtils.nvlToEmptyStr(order.getCreateTime()));
			salesOrderGroupQueryResponse.setModifierCode(nvlToEmptyUtils.nvlToEmptyStr(order.getModifierCode()));
			salesOrderGroupQueryResponse.setModifierName(nvlToEmptyUtils.nvlToEmptyStr(order.getModifierName()));
			salesOrderGroupQueryResponse.setModifierTime(nvlToEmptyUtils.nvlToEmptyStr(order.getModifierTime()));
			salesOrderGroupQueryResponse.setCustomerPurchaseOrderNo(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerPurchaseOrderNo()));
			salesOrderGroupQueryResponse.setCustomerPurchaseDate(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerPurchaseDate()));
			salesOrderGroupQueryResponse.setOrderReasonCode(nvlToEmptyUtils.nvlToEmptyStr(order.getOrderReasonCode()));
			salesOrderGroupQueryResponse.setOrderReasonName(nvlToEmptyUtils.nvlToEmptyStr(order.getOrderReasonName()));
			salesOrderGroupQueryResponse.setBizFeatures(nvlToEmptyUtils.nvlToEmptyStr(order.getBizFeatures()));
			salesOrderGroupQueryResponse.setNote(nvlToEmptyUtils.nvlToEmptyStr(order.getNote()));
			salesOrderGroupQueryResponse.setReceiveWarehouseCode(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveWarehouseCode()));
			salesOrderGroupQueryResponse.setReceiveWarehouseName(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveWarehouseName()));
			salesOrderGroupQueryResponse.setReceiveFactoryCode(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveFactoryCode()));
			salesOrderGroupQueryResponse.setReceiveFactoryName(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveFactoryName()));
			salesOrderGroupQueryResponse.setReceiveStockCode(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveStockCode()));
			salesOrderGroupQueryResponse.setReceiveStockName(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveStockName()));
			salesOrderGroupQueryResponse.setShippingWarehouseCode(nvlToEmptyUtils.nvlToEmptyStr(order.getShippingWarehouseCode()));
			salesOrderGroupQueryResponse.setShippingWarehouseName(nvlToEmptyUtils.nvlToEmptyStr(order.getShippingWarehouseName()));
			salesOrderGroupQueryResponse.setSalesOrderNo(nvlToEmptyUtils.nvlToEmptyStr(order.getSalesOrderNo()));
			salesOrderGroupQueryResponse.setRelationNo(nvlToEmptyUtils.nvlToEmptyStr(order.getRelatonNo()));
			salesOrderGroupQueryResponse.setCustomerGroup(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerGroup()));
			salesOrderGroupQueryResponse.setCustomerGrade(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerGrade()));
			salesOrderGroupQueryResponse.setFulfillmentTypeCode(order.getFulfillmentTypeCode());
			salesOrderGroupQueryResponse.setFulfillmentPriority(order.getFulfillmentPriority());
			salesOrderGroupQueryResponse.setAutoFulfillment(nvlToEmptyUtils.nvlToEmptyStr(order.getAutoFulfillment()));
			salesOrderGroupQueryResponse.setReceiveStatus(nvlToEmptyUtils.nvlToEmptyStr(order.getReceiveStatus()));
			salesOrderGroupQueryResponse.setOrderBizTag(order.getOrderBizTag());
			salesOrderGroupQueryResponse.setCustomerGroupName(nvlToEmptyUtils.nvlToEmptyStr(order.getCustomerGroupName()));
			List<SalesOrderAtomQueryDetailResponse> orderDetaislList = order.getOrderDetails();
			// 转换子单
			List<SalesOrderGroupQueryDetailResponse> salesOrderGroupQueryDetailResponseList = new ArrayList<>(orderDetaislList.size());
			SalesOrderGroupQueryDetailResponse salesOrderGroupQueryDetailResponse = null;
			for (SalesOrderAtomQueryDetailResponse orderDetail : orderDetaislList) {
				salesOrderGroupQueryDetailResponse = new SalesOrderGroupQueryDetailResponse();
				salesOrderGroupQueryDetailResponse.setLineNum(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getLineNum()));
				salesOrderGroupQueryDetailResponse.setSourceLineNum(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getSourceLineNum()));
				salesOrderGroupQueryDetailResponse.setOutLineNum(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getOutLineNum()));
				salesOrderGroupQueryDetailResponse.setStatus(orderDetail.getStatus());
				salesOrderGroupQueryDetailResponse.setInnerProductCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getInnerProductCode()));
				salesOrderGroupQueryDetailResponse.setInnerProductName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getInnerProductName()));
				salesOrderGroupQueryDetailResponse.setProductBarCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getProductBarCode()));
				salesOrderGroupQueryDetailResponse.setProductCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getProductCode()));
				salesOrderGroupQueryDetailResponse.setProductName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getProductName()));
				salesOrderGroupQueryDetailResponse.setProductQuantity(orderDetail.getProductQuantity());
				salesOrderGroupQueryDetailResponse.setSalesUnitCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getSalesUnitCode()));
				salesOrderGroupQueryDetailResponse.setSalesUnitName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getSalesUnitName()));
				salesOrderGroupQueryDetailResponse.setStockUnitCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getStockUnitCode()));
				salesOrderGroupQueryDetailResponse.setStockUnitName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getStockUnitName()));
				salesOrderGroupQueryDetailResponse.setUnitConversionRelationship(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getUnitConversionRelationship()));
				salesOrderGroupQueryDetailResponse.setShippingWarehouseCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getShippingWarehouseCode()));
				salesOrderGroupQueryDetailResponse.setShippingWarehouseName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getShippingWarehouseName()));
				salesOrderGroupQueryDetailResponse.setDeliveryFactoryCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getDeliveryFactoryCode()));
				salesOrderGroupQueryDetailResponse.setDeliveryFactoryName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getDeliveryFactoryName()));
				salesOrderGroupQueryDetailResponse.setStockCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getStockCode()));
				salesOrderGroupQueryDetailResponse.setStockName(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getStockName()));
				salesOrderGroupQueryDetailResponse.setCumulativePlanDeliveryQuantity(orderDetail.getCumulativePlanDeliveryQuantity());
				salesOrderGroupQueryDetailResponse.setCumulativeDeliveryQuantity(orderDetail.getCumulativeDeliveryQuantity());
				salesOrderGroupQueryDetailResponse.setUnitPrice(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getUnitPrice()));
				salesOrderGroupQueryDetailResponse.setTotalAmount(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getTotalAmount()));
				salesOrderGroupQueryDetailResponse.setIsClose(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getIsClose()));
				salesOrderGroupQueryDetailResponse.setCloseCode(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getCloseCode()));
				salesOrderGroupQueryDetailResponse.setCloseMsg(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getCloseMsg()));
				salesOrderGroupQueryDetailResponse.setNote(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getNote()));
				salesOrderGroupQueryDetailResponse.setBizFeatures(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getBizFeatures()));
				salesOrderGroupQueryDetailResponse.setConfirmQuantity(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getConfirmQuantity()));
				salesOrderGroupQueryDetailResponse.setGiftQuantity(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getGiftQuantity()));
				salesOrderGroupQueryDetailResponse.setTaxRate(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getTaxRate()));
				salesOrderGroupQueryDetailResponse.setProductionDate(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getProductationTime()));
				salesOrderGroupQueryDetailResponse.setActivityPrice(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getActivityPrice()));
				salesOrderGroupQueryDetailResponse.setActivityTotalAmount(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getTotalActivityFee()));
				salesOrderGroupQueryDetailResponse.setRelationLineNum(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getRelationLineNo()));
				salesOrderGroupQueryDetailResponse.setCumulativeNoticeQuantity(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getCumulativeNoticeQuantity()));
				salesOrderGroupQueryDetailResponse.setCumulativeWaitOutboundQuantity(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getCumulativeWaitOutboundQuantity()));
				salesOrderGroupQueryDetailResponse.setCumulativeReceivedQuantity(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getCumulativeReceivedQuantity()));
				salesOrderGroupQueryDetailResponse.setStockConversionNum(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getStockConversionNum()));
				salesOrderGroupQueryDetailResponse.setReceiveStatus(nvlToEmptyUtils.nvlToEmptyStr(orderDetail.getReceiveStatus()));
				salesOrderGroupQueryDetailResponseList.add(salesOrderGroupQueryDetailResponse);
			}
			salesOrderGroupQueryResponse.setOrderDetails(salesOrderGroupQueryDetailResponseList);
			response.add(salesOrderGroupQueryResponse);
		}
		return response;
	}
}
